package com.hzcx.app.simplechat.ui.friend.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.ui.friend.bean.FriendLableListBean;
import com.mcxtzhang.swipemenulib.SwipeMenuLayout;

import java.util.List;

public class FriendLableListAdapter extends BaseQuickAdapter<FriendLableListBean, BaseViewHolder> {

    private boolean isMenuEnabled = true;

    public FriendLableListAdapter(@Nullable List<FriendLableListBean> data) {
        this(data, true);
    }

    public FriendLableListAdapter(@Nullable List<FriendLableListBean> data, boolean isMenuEnabled) {
        super(R.layout.rv_item_friend_lable, data);
        this.isMenuEnabled = isMenuEnabled;
    }

    @Override
    protected void convert(BaseViewHolder helper, FriendLableListBean item) {

        SwipeMenuLayout swipe_menu = helper.getView(R.id.swipe_menu);
        swipe_menu.setSwipeEnable(isMenuEnabled);
        ImageView ivCheckBox = helper.getView(R.id.iv_check_box);
        if (isMenuEnabled) {
            ivCheckBox.setVisibility(View.GONE);
        } else {
            ivCheckBox.setVisibility(View.VISIBLE);
        }

        if (item.isChecked()) {
            ivCheckBox.setImageResource(R.mipmap.ic_icon_check_select);
        } else {
            ivCheckBox.setImageResource(R.mipmap.ic_icon_check_normal);
        }

        helper.setText(R.id.tv_lable_name, item.getName() + "（" + item.getMember_count() + ")");
        helper.setText(R.id.tv_content, item.getMembers_name());

        helper.addOnClickListener(R.id.tv_delete, R.id.cons_content);
    }
}
